Core.Test.registerTest({
	group: "storage",
	name: "Core.Storage.notify()",
	
	before: function() {
		Core.Test.Logger.activate();
	},
	
	"Should set NP as dirty when Storage is running (direct match)" : function() {
		Core.Storage.register("test.children.0", Res.Storage.ListenerA);

		Core.Storage.set("test.children.0", true);
		Core.Storage.Notifier.notify();
		
		Core.Test.Logger.assertFlow(["ListenerA notified"]);
	},
	
	"Should set NP as dirty when Storage is running (indirect match)" : function() {
		Core.Storage.register("test.children.0", Res.Storage.ListenerA);
		
		Core.Storage.set("test.children.0.21", true);
		Core.Storage.Notifier.notify();
		
		Core.Test.Logger.assertFlow(["ListenerA notified"]);
	},
	
	"Shouldn't set NP as dirty when Storage is NOT running": function() {
		Core.App.stop();
		Core.Storage.register("test.children.0", Res.Storage.ListenerA);
		Core.Storage.set("test.children.0", true);
		Core.Storage.Notifier.notify();
		
		Core.Test.Logger.assertSize(0);
		Core.App.start();
	},
	
	"Should invoke listener once only in single notify-loop (1)": function() {
		Core.Storage.register("test.children.0", Res.Storage.ListenerA);
		Core.Storage.register("test.children.1", Res.Storage.ListenerA);
		
		Core.Storage.set("test.children.0", true);
		Core.Storage.set("test.children.1", true);
		Core.Storage.Notifier.notify();
		
		Core.Test.Logger.assertFlow(["ListenerA notified"]);
	},
	
	"Should invoke listener once only in single notify-loop (2)": function() {
		Core.Storage.register("test.children.1", Res.Storage.ListenerA);
		Core.Storage.register("test.children.2", Res.Storage.ListenerA);
		Core.Storage.register("test.children.2", Res.Storage.ListenerB);
		
		Core.Storage.set("test.children.1", true);
		Core.Storage.set("test.children.2", true);
		Core.Storage.Notifier.notify();
		
		Core.Test.Logger.assertFlow(["ListenerA notified", "ListenerB notified"]);
	},
	
	"Should invoke 3-phase notify process": function() {
		Core.Storage.register("test.children.3", Res.Storage.ListenerC);
		Core.Storage.register("test.children.4", Res.Storage.ListenerD);
		Core.Storage.register("test.children.5", Res.Storage.ListenerE);
		
		Core.Storage.set("test.children.3", true);
		Core.Storage.Notifier.notify();
		
		Core.Test.Logger.assertFlow(["ListenerC notified", "ListenerD notified", "ListenerE notified"]);
	},
	
	"Should invoke 3-phase notify process with repetitive listeners": function() {
		Core.Storage.register("test.children.3", Res.Storage.ListenerC);
		Core.Storage.register("test.children.4", Res.Storage.ListenerE);
		Core.Storage.register("test.children.4", Res.Storage.ListenerD);
		Core.Storage.register("test.children.5", Res.Storage.ListenerE);
		
		Core.Storage.set("test.children.3", true);
		Core.Storage.Notifier.notify();
		
		Core.Test.Logger.assertFlow(["ListenerC notified", "ListenerE notified", "ListenerD notified", "ListenerE notified"]);
	}
});